package com.bbz.crawler.controller;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.plugins.Page;
import com.bbz.crawler.core.commen.model.CrawlerResult;
import com.bbz.crawler.service.ICrawlerResultService;
/**
 * <p>
 * CrawlerResultController
 * </p>
 *
 * @author binbin.a.zhang123
 * @since 2018-05-29
 */
@RestController
@RequestMapping("/crawlerResult")
public class CrawlerResultController  {

    @Autowired
    private ICrawlerResultService crawlerResultService;

    /**
     * 跳转到添加页面CrawlerResult
     */
    @RequestMapping("/addCrawlerResult")
    public String crawlerResultAdd() {
        return  "addCrawlerResult.html";
    }

    /**
     * 跳转到编辑页面CrawlerResult
     */
    @RequestMapping("/editCrawlerResult/{crawlerResultId}")
    public String editCrawlerResult(@PathVariable Integer crawlerResultId, ModelMap model) {
        CrawlerResult crawlerResult = crawlerResultService.selectById(crawlerResultId);
        model.addAttribute("item",crawlerResult);
        return "editCrawlerResult.html";
    }

    /**
     * 获取CrawlerResult列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return crawlerResultService.selectList(null);
    }

  	/**
     * 获取CrawlerResult列表
     */
    @RequestMapping(value = "/list/page/{page}/size/{size}")
    @ResponseBody
    public Object listPage(@PathVariable Integer page, @PathVariable Integer size) {
        return crawlerResultService.selectMapsPage(new Page<>(page, size), null);
    }
    
    /**
     * 新增CrawlerResult
     */
    @RequestMapping(value = "/add")
    public Object add(CrawlerResult crawlerResult) {
        crawlerResultService.insert(crawlerResult);
        return null;
    }

    /**
     * 删除CrawlerResult
     */
    @RequestMapping(value = "/delete")
    public Object delete(@RequestParam Integer crawlerResultId) {
        crawlerResultService.deleteById(crawlerResultId);
        return null;
    }

    /**
     * 修改CrawlerResult
     */
    @RequestMapping(value = "/update")
    public Object update(CrawlerResult crawlerResult) {
        crawlerResultService.updateById(crawlerResult);
        return null;
    }

    /**
     * CrawlerResult详情
     */
    @RequestMapping(value = "/detail/{crawlerResultId}")
    public Object detail(@PathVariable("crawlerResultId") Integer crawlerResultId) {
        return crawlerResultService.selectById(crawlerResultId);
    }
}
